public class Test_MyLinkedList {

    public static void main(String[] args) {

        MyLinkedList list = new MyLinkedList();
        list.addFirst(10);
        list.addFirst(20);
        list.addFirst(30);
        list.addFirst(40);
        System.out.println("创建一个双向链表，依次头插法添加10，20,30,40， 结果为：");
        list.display();

        list.addLast(50);
        list.addLast(60);
        list.addLast(70);
        list.addLast(80);
        System.out.println("依次尾插法添加50,60,70,80， 结果为：");
        list.display();

        System.out.println("测试：在任意（合法）位置插入元素");
        list.addIndex(3,3);
        list.display();
        System.out.println("==================================");
        list.addIndex(4,4);
        list.display();
        System.out.println("==================================");
        list.addIndex(5,5);
        list.addIndex(6,6);
        System.out.println("3-3,4-4,5-5,6-6");
        System.out.println("插入结果为：");
        list.display();

        System.out.println("判断是否存在这几个元素：1,30,6,22");
        System.out.println(list.contains(1));
        System.out.println(list.contains(30));
        System.out.println(list.contains(6));
        System.out.println(list.contains(22));


        System.out.println("删除与所给元素相等的第一个元素：比如40");
        System.out.println("删除前：");
        list.display();
        list.remove(40);
        System.out.println("删除后：");
        list.display();
        System.out.println("再依次删除1,3,70");
        list.remove(1);
        list.remove(3);
        list.remove(70);
        System.out.println("删除后的结果为：");
        list.display();


        System.out.println("删除与所给元素相等的所有节点：");
        System.out.println("先添加几个一样的元素：");
        list.addIndex(5,888);
        list.addIndex(10,888);
        list.addIndex(8,888);
        list.addIndex(1,888);
        System.out.println("删除之前:");
        list.display();
        list.removeAllKey(888);
        System.out.println("删除之后：");
        list.display();

        System.out.println("删除30");
        list.remove(30);
        System.out.println("删除之后：");
        list.display();

        System.out.println("当前链表节点个数为："+list.size());

        System.out.println("清空当前链表：");
        list.clear();
        list.display();
        System.out.println("看到我这句，说明已经清空啦，并且已经再次display过了");


    }

}
